Load your data and plot the figures. The following code reads the data and plots the figures. The cs object is the result of the cytosignal analysis, and the colors.list object is the color list for the ligands and receptors. The plot.path variable specifies the output directory for the figures.

library(cytosignal)
source("path_to_plotting_functions.R")

cs <- readRDS("path/to/cs-obj_E12.5_E1S1.rds")
cs.e1s2 = readRDS("path/to/cs-obj_E12.5_E1S2.rds")

colors.list <- readRDS("path/to/st.color.list.rds")
colors.list <- colors.list[levels(cs@clusters)]

colors.list.e1s2 <- readRDS("path/to/st.color.list.rds")
colors.list.e1s2 <- colors.list.e1s2[levels(cs.e1s2@clusters)]

Plot CytoSignal outputs

Specify the ligand-receptor interaction to plot. The use.intr variable specifies the ligand-receptor interaction to plot. Now plot the first example of FGF8-FGFR1 interaction, which is a diffusino-dependent interaction.

signif.use <- "result.hq"
lrscore.slot <- "diffusion-Raw_smooth"
intr.names <- cytosignal:::getIntrNames(cs, showIntr(cs, lrscore.slot, signif.use))

use.intr = "FGF8-FGFR1"
use.CPI = names(intr.names[which(intr.names == use.intr)])
plot.rank = which(intr.names == use.intr)

plotSignif2(cs, intr = plot.rank, edge = T, pt.size = 0.1, raster = F, resolution = 200,
            colors.list = colors.list, slot.use = lrscore.slot, signif.use = signif.use, 
            return.plot = T)
## $`FGF8-FGFR1`

Now plot the second example of DLL1-NOTC1 interaction.

signif.use <- "result.hq"
lrscore.slot <- "contact-Raw_smooth"
intr.names <- cytosignal:::getIntrNames(cs.e1s2, showIntr(cs.e1s2, lrscore.slot, signif.use))

use.intr = "DLL1-NOTC1"
use.CPI = names(intr.names[which(intr.names == use.intr)])
plot.rank = which(intr.names == use.intr)

plotSignif2(cs.e1s2, intr = plot.rank, edge = T, pt.size = 0.1, raster = F, resolution = 200,
            colors.list = colors.list.e1s2, slot.use = lrscore.slot, signif.use = signif.use, 
            return.plot = T)
## $`DLL1-NOTC1`

Circos plot

Plot the circos plot for the all diffusion-dependent interactions.

slot.use = "diffusion-Raw_smooth"

edge.df = getNormEdgeDF(cs, db.use = slot.use)
edge.mtx = DFtoMtx(edge.df)
clust.col = colors.list[c(rownames(edge.mtx), colnames(edge.mtx))]

# abbreviate the row and column names to two letters
edge.mtx.1 = edge.mtx

rownames(edge.mtx.1) = paste0("s-", rownames(edge.mtx.1))
colnames(edge.mtx.1) = paste0("r-", colnames(edge.mtx.1))

names(clust.col) = c(rownames(edge.mtx.1), colnames(edge.mtx.1))

# set the order based on the rowSums and colSums
col.order = colnames(edge.mtx.1)[order(colSums(edge.mtx.1), decreasing = T)]
row.order = rownames(edge.mtx.1)[order(rowSums(edge.mtx.1), decreasing = F)]

# chordDiagram takes union(rownames, colnames) as the order
use.order = c(row.order, col.order)

# plotting circos
circos.clear()
circos.par("track.height"=0.8, cell.padding=c(0, 0, 0, 0))
par(cex = 1, mar = c(0, 0, 0, 0))

chordDiagram(
  edge.mtx.1, big.gap = 15, grid.col = clust.col, annotationTrack = "grid", order = use.order,
  annotationTrackHeight = c(0.03, 0.01),
  preAllocateTracks = list(
    track.height = max(strwidth(unlist(dimnames(edge.mtx.1))))/2
  )
)

circos.track(
  track.index = 1, panel.fun = function(x, y) {
    circos.text(
      CELL_META$xcenter, CELL_META$ylim[1], 
      CELL_META$sector.index, facing = "clockwise", 
      niceFacing = TRUE, adj = c(0, 0.5),
      cex = 0.8
    )
  }, bg.border = NA
)

Plot the circos plot for the all contact-dependent interactions.

slot.use = "contact-Raw_smooth"

edge.df = getNormEdgeDF(cs.e1s2, db.use = slot.use)
edge.mtx = DFtoMtx(edge.df)
clust.col = colors.list.e1s2[c(rownames(edge.mtx), colnames(edge.mtx))]

# abbreviate the row and column names to two letters
edge.mtx.1 = edge.mtx

rownames(edge.mtx.1) = paste0("s-", rownames(edge.mtx.1))
colnames(edge.mtx.1) = paste0("r-", colnames(edge.mtx.1))

names(clust.col) = c(rownames(edge.mtx.1), colnames(edge.mtx.1))

# set the order based on the rowSums and colSums
col.order = colnames(edge.mtx.1)[order(colSums(edge.mtx.1), decreasing = T)]
row.order = rownames(edge.mtx.1)[order(rowSums(edge.mtx.1), decreasing = F)]

# chordDiagram takes union(rownames, colnames) as the order
use.order = c(row.order, col.order)
# plotting circos
circos.clear()
circos.par("track.height"=0.8, cell.padding=c(0, 0, 0, 0))
par(cex = 1, mar = c(0, 0, 0, 0))

chordDiagram(
  edge.mtx.1, big.gap = 15, grid.col = clust.col, annotationTrack = "grid", order = use.order,
  annotationTrackHeight = c(0.03, 0.01),
  preAllocateTracks = list(
    track.height = max(strwidth(unlist(dimnames(edge.mtx.1))))/2
  )
)

circos.track(
  track.index = 1, panel.fun = function(x, y) {
    circos.text(
      CELL_META$xcenter, CELL_META$ylim[1], 
      CELL_META$sector.index, facing = "clockwise", 
      niceFacing = TRUE, adj = c(0, 0.5),
      cex = 0.8
    )
  }, bg.border = NA
)

Spatial heatmaps colored by the total number of significant interactions per cell over timpepoints

First read the number of significant interactions at each timepoint in the focused region.

sig_num_per_cell <- readRDS("path/to/sig_intr_across_tp.rds")
plotSigWrap(sig_num_per_cell, plot.class = "counts", pt.size = 0.06, pt.stroke = 0.15, legend.pos = "none")